﻿using System;
using UnityEngine;
using UnityEngine.PostProcessing;

// Token: 0x0200038F RID: 911
[RequireComponent(typeof(PostProcessingBehaviour))]
public class PostProcessingChanger : MonoBehaviour
{
	// Token: 0x06001671 RID: 5745 RVA: 0x00095EA0 File Offset: 0x000940A0
	private void Awake()
	{
		this.postProcessingBehaviour = base.GetComponent<PostProcessingBehaviour>();
		for (int i = 0; i < this.profileSets.Length; i++)
		{
			this.profileSets[i].Setup();
		}
		this.ChangeBaseProfile(this.profileNo);
	}

	// Token: 0x06001672 RID: 5746 RVA: 0x00095EEC File Offset: 0x000940EC
	public void ChangeBaseProfile(int no)
	{
		UnityEngine.Object.Destroy(this.instantiateProfile);
		this.instantiateProfile = UnityEngine.Object.Instantiate<PostProcessingProfile>(this.profileSets[no].profile);
		this.instantiateProfile.name = "InstantiateProfile";
		this.postProcessingBehaviour.profile = this.instantiateProfile;
		this.SetChange(no);
	}

	// Token: 0x06001673 RID: 5747 RVA: 0x00095F44 File Offset: 0x00094144
	private void SetChange(int no)
	{
		this.profileNo = no;
		this.instantiateProfile.bloom.enabled = this.bloomEnable;
		BloomModel.Settings settings = this.instantiateProfile.bloom.settings;
		settings.bloom.intensity = this.profileSets[no].bloomIntensity * this.bloomRate;
		settings.lensDirt.texture = ((!this.lensDirtEnable) ? null : this.dirtTex);
		this.instantiateProfile.bloom.settings = settings;
		this.instantiateProfile.eyeAdaptation.enabled = this.eyeAdaptationEnable;
		EyeAdaptationModel.Settings settings2 = this.instantiateProfile.eyeAdaptation.settings;
		settings2.exposureCompensation = this.exposureCompensation;
		this.instantiateProfile.eyeAdaptation.settings = settings2;
		this.instantiateProfile.vignette.enabled = this.vignetteEnable;
		VignetteModel.Settings settings3 = this.instantiateProfile.vignette.settings;
		settings3.intensity = this.profileSets[no].vignetteIntensity * this.vignetteRate;
		this.instantiateProfile.vignette.settings = settings3;
		this.instantiateProfile.chromaticAberration.enabled = this.noiseEnable;
		ChromaticAberrationModel.Settings settings4 = this.instantiateProfile.chromaticAberration.settings;
		settings4.intensity = this.profileSets[no].chromaticAberrationIntensity * this.noiseRate;
		this.instantiateProfile.chromaticAberration.settings = settings4;
		this.instantiateProfile.grain.enabled = this.noiseEnable;
		GrainModel.Settings settings5 = this.instantiateProfile.grain.settings;
		settings5.intensity = this.profileSets[no].grainIntensity * this.noiseRate;
		this.instantiateProfile.grain.settings = settings5;
	}

	// Token: 0x06001674 RID: 5748 RVA: 0x00096114 File Offset: 0x00094314
	private void OnValidate()
	{
		this.isUpdate = true;
	}

	// Token: 0x06001675 RID: 5749 RVA: 0x00096120 File Offset: 0x00094320
	private void Update()
	{
		if (this.isUpdate)
		{
			this.SetChange(this.profileNo);
		}
	}

	// Token: 0x04001A2F RID: 6703
	private PostProcessingBehaviour postProcessingBehaviour;

	// Token: 0x04001A30 RID: 6704
	public ProfileSet[] profileSets;

	// Token: 0x04001A31 RID: 6705
	private PostProcessingProfile instantiateProfile;

	// Token: 0x04001A32 RID: 6706
	public int profileNo;

	// Token: 0x04001A33 RID: 6707
	public bool eyeAdaptationEnable;

	// Token: 0x04001A34 RID: 6708
	public float exposureCompensation = 0.55f;

	// Token: 0x04001A35 RID: 6709
	public bool bloomEnable;

	// Token: 0x04001A36 RID: 6710
	[Range(0f, 2f)]
	public float bloomRate = 1f;

	// Token: 0x04001A37 RID: 6711
	public bool lensDirtEnable;

	// Token: 0x04001A38 RID: 6712
	public Texture dirtTex;

	// Token: 0x04001A39 RID: 6713
	public bool vignetteEnable = true;

	// Token: 0x04001A3A RID: 6714
	[Range(0f, 2f)]
	public float vignetteRate = 1f;

	// Token: 0x04001A3B RID: 6715
	public bool noiseEnable;

	// Token: 0x04001A3C RID: 6716
	[Range(0f, 2f)]
	public float noiseRate = 1f;

	// Token: 0x04001A3D RID: 6717
	private bool isUpdate;
}
